package cn.wxq.daily.empdailymgforserve.service.impl;
import cn.wxq.daily.empdailymgforserve.domain.ReimbursementAudit;
import cn.wxq.daily.empdailymgforserve.domain.Reimbursement;
import cn.wxq.daily.empdailymgforserve.mapper.ReimbursementAuditDao;
import cn.wxq.daily.empdailymgforserve.mapper.ReimbursementDao;
import cn.wxq.daily.empdailymgforserve.service.ReimbursementAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 费用审核业务层
 */
@Service
public class ReimbursementAuditServiceImpl implements ReimbursementAuditService {
    @Autowired
    private ReimbursementAuditDao reimbursementAuditDao;

    @Autowired
    private ReimbursementDao reimbursementDao;

    /**
     * 费用审核
     * @param reimbursementAudit
     * @return
     */
    @Override
    public int insertAuditInfo(ReimbursementAudit reimbursementAudit) {
        /**
         * 关联薪资
         */
        //设置审核状态
        Reimbursement reimbursement = new Reimbursement();
        reimbursement.setReimStatus("1");
        reimbursement.setReimId(reimbursementAudit.getReimId());
        //更新审核状态
        int upStatus = reimbursementDao.updateReimbursement(reimbursement);
        if (upStatus >0){
            //设置审核时间
            reimbursementAudit.setAuditTime(new Date());

            return reimbursementAuditDao.insertAuditInfo(reimbursementAudit);

        }else {
            return 0;
        }


    }
}
